- dashboard = local_assigns[:dashboard]
- custom_dom_id = dom_id(@project ? milestone : milestone.milestones.first)

%li{class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: custom_dom_id }
  .row
    .col-sm-6
      %strong= link_to_gfm truncate(milestone.title, length: 100), milestone_path
    .col-sm-6
      .pull-right.light #{milestone.percent_complete(current_user)}% 完成
  .row
    .col-sm-6
      = link_to pluralize(milestone.issues_visible_to_user(current_user).size, '个问题', '个问题'), issues_path
      &middot;
      = link_to pluralize(milestone.merge_requests.size, '个合并请求', '个合并请求'), merge_requests_path
    .col-sm-6= milestone_progress_bar(milestone)
  - if milestone.is_a?(GlobalMilestone)
    .row
      .col-sm-6
        .expiration= render('shared/milestone_expired', milestone: milestone)
        .projects
          - milestone.milestones.each do |milestone|
            = link_to milestone_path(milestone) do
              %span.label.label-gray
                = dashboard ? milestone.project.name_with_namespace : milestone.project.name
      - if @group
        .col-sm-6
          - if can?(current_user, :admin_milestones, @group)
            - if milestone.closed?
              = link_to '重新打开里程碑', group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: {state_event: :activate }), method: :put, class: "btn btn-xs btn-grouped btn-reopen"
            - else
              = link_to '关闭里程碑', group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: {state_event: :close }), method: :put, class: "btn btn-xs btn-close"

  - if @project
    .row
      .col-sm-6= render('shared/milestone_expired', milestone: milestone)
      .col-sm-6
        - if can?(current_user, :admin_milestone, milestone.project) and milestone.active?
          = link_to edit_namespace_project_milestone_path(milestone.project.namespace, milestone.project, milestone), class: "btn btn-xs" do
            = icon('pencil-square-o')
            编辑
          \
          = link_to '关闭里程碑', namespace_project_milestone_path(@project.namespace, @project, milestone, milestone: {state_event: :close }), method: :put, remote: true, class: "btn btn-xs btn-close"
          = link_to namespace_project_milestone_path(milestone.project.namespace, milestone.project, milestone), data: { confirm: '确定要继续么？' }, method: :delete, class: "btn btn-xs btn-remove" do
            = icon('trash-o')
            删除
